package com.uuuo.gamesdk;

import android.content.Context;
import android.os.Environment;
import android.util.Log;
import android.widget.Toast;

import com.uuuo.gamesdk.utils.FixBugManager;

import java.io.File;

/**
 * Created by JiaTao on 2017/11/8.
 * Email: 535318720@qq.com
 * Version: 1.0
 * Description:
 */

public class UGameSDK {
    private static final String TAG = "******UGameSDK******";
    private static UGameSDK instance;

    public static final UGameSDK getInstance() {
        if (instance == null) {
            synchronized (UGameSDK.class) {
                if (instance == null) {
                    instance = new UGameSDK();
                }
            }
        }
        return instance;
    }

    public void fixBug(Context context){
        File fixFile = new File(Environment.getExternalStorageDirectory(), "fix.dex");
        if (fixFile.exists()) {
            FixBugManager manager = new FixBugManager(context);
            try {
                manager.fixDex(fixFile.getAbsolutePath());
                Toast.makeText(context, "修复成功!", Toast.LENGTH_SHORT).show();
            } catch (Exception e) {
                e.printStackTrace();
                Toast.makeText(context, "修复失败!", Toast.LENGTH_SHORT).show();
            }
        }
    }

    public void init(Context context) {
        Toast.makeText(context, "这是修复Bug的代码", Toast.LENGTH_SHORT).show();
    }

    public void login() {
        Person person = new Person();
        person.setName("jia");
        person.setAge(20);

        Log.i(TAG, person.toString());
    }
}
